import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

/**
 * tester class for the chacking account class.
 * @author Kyle Scharnhorst/Kristopher Gooding
 * @version 04/25/2014
 */
public class CheckingAccountTest {

	/**checking account 1 to test.*/
	private CheckingAccount my_account_tester1;
	/**checking account 2 to test.*/
	private CheckingAccount my_account_tester2;
	/**checking account 3 to test.*/
	private CheckingAccount my_account_tester3;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		my_account_tester1 = new CheckingAccount("Bob", "123 st", "12345",
				"bobtown", "bobcountry");
		my_account_tester2 = new CheckingAccount("Bob", "123 st", "12345",
				"bobtown", "bobcountry", 123456);
		my_account_tester3 = new CheckingAccount(1);
	}

	/**
	 * Test method for
	 * {@link CheckingAccount#CheckingAccount(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)}
	 * .
	 */
	@Test
	public void testCheckingAccount() {
		assertTrue("Bob".equals(my_account_tester1.getMember().getName()));
		assertTrue("123 st".equals(my_account_tester1.getMember()
				.getAddress().getStreet()));
		assertTrue("12345".equals(my_account_tester1.getMember()
				.getAddress().getZipCode()));
		assertTrue("bobtown".equals(my_account_tester1.getMember()
				.getAddress().getTown()));
		assertTrue("bobcountry".equals(my_account_tester1.getMember()
				.getAddress().getCountry()));
	}

	/**
	 * Test method for
	 * {@link CheckingAccount#CheckingAccount(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, float)}
	 * .
	 */
	@Test
	public void testCheckingAccountFloat() {
		assertTrue("Bob".equals(my_account_tester2.getMember().getName()));
		assertTrue("123 st".equals(my_account_tester2.getMember()
				.getAddress().getStreet()));
		assertTrue("12345".equals(my_account_tester2.getMember()
				.getAddress().getZipCode()));
		assertTrue("bobtown".equals(my_account_tester2.getMember()
				.getAddress().getTown()));
		assertTrue("bobcountry".equals(my_account_tester2.getMember()
				.getAddress().getCountry()));
		assertEquals(123456, my_account_tester2.getDebitAmount(), 0);
	}

	/**
	 * Test method for {@link CheckingAccount#CheckingAccount(int)}.
	 */
	@Test
	public void testCheckingAccountInt() {
		assertEquals(my_account_tester3.getAccountNumber(), 1);
	}

	/**
	 * Test method for {@link CheckingAccount#determineCosts()}.
	 */
	@Test
	public void testDetermineCosts() {
		my_account_tester1.determineCosts();
		assertEquals(my_account_tester1.getBalance(), -0.953, 0);
		my_account_tester1.setBalance(10000);
		//System.out.println(my_account_tester1.getBalance());
		my_account_tester1.determineCosts();
		assertEquals(my_account_tester1.getBalance(), 9999, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#print()}.
	 */
	@Test
	public void testPrint() {
		// assertTrue(true);
		my_account_tester1.print();
		my_account_tester2.print();
	}

	/**
	 * Test method for {@link CheckingAccount#withdrawal(double)}.
	 */
	@Test
	public void testWithdrawal() {
		assertEquals(my_account_tester1.getDebitAmount(), 0, 0);
		my_account_tester1.increaseBalance(100);
		assertEquals(my_account_tester1.getBalance(), 100, 0);

		assertFalse(my_account_tester1.withdrawal(50));
		assertEquals(my_account_tester1.getBalance(), 100, 0);
		assertFalse(my_account_tester1.withdrawal(110));
		
		//System.out.println("FUUUUUUUUUUU " + my_account_tester2.getDebitAmount() + "faaaa " + my_account_tester2.getBalance());
		assertTrue(my_account_tester2.withdrawal(666666));
		
	}

	/**
	 * Test method for {@link CheckingAccount#verseMoney(double)}.
	 */
	@Test
	public void testVerseMoney() {
		my_account_tester1.increaseBalance(100);
		my_account_tester1.verseMoney(1000);
		assertEquals(my_account_tester1.getBalance(), 1100, 0);
	}

	/**
	 * Test method for
	 * {@link CheckingAccount#applyForCreditCard(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int)}
	 * .
	 */
	@Test
	public void testApplyForCreditCard() {
		my_account_tester1.decreaseBalance(100);
		assertFalse(my_account_tester1.applyForCreditCard("Bob", "123 st",
				"12345", "bobtown", "bobcountry", 1));
		my_account_tester1.increaseBalance(100);
		assertTrue(my_account_tester1.applyForCreditCard("Bob", "123 st",
				"12345", "bobtown", "bobcountry", 1));
		my_account_tester1.increaseBalance(30000);
		assertTrue(my_account_tester1.applyForCreditCard("Bob", "123 st",
				"12345", "bobtown", "bobcountry", 1));

	}

	/**
	 * Test method for {@link CheckingAccount#getBalance()}.
	 */
	@Test
	public void testGetBalance() {
		assertEquals(my_account_tester1.getBalance(), 0, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#increaseBalance(double)}.
	 */
	@Test
	public void testIncreaseBalance() {
		assertEquals(my_account_tester1.getDebitAmount(), 0, 0);
		my_account_tester1.increaseBalance(100);
		assertEquals(my_account_tester1.getBalance(), 100, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#decreaseBalance(double)}.
	 */
	@Test
	public void testDecreaseBalance() {
		assertEquals(my_account_tester1.getDebitAmount(), 0, 0);
		my_account_tester1.decreaseBalance(100);
		assertEquals(my_account_tester1.getDebitAmount(), 0, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#getDebitAmount()}.
	 */
	@Test
	public void testGetDebitAmount() {
		assertEquals(my_account_tester1.getDebitAmount(), 0, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#setBalance(double)}.
	 */
	@Test
	public void testSetBalance() {
		my_account_tester1.setBalance(1000);
		assertEquals(my_account_tester1.getBalance(), 1000, 0);
	}

	/**
	 * Test method for {@link CheckingAccount#getAccountNumber()}.
	 */
	@Test
	public void testGetAccountNumber() {
		assertEquals(my_account_tester3.getAccountNumber(), 1);
	}

	/**
	 * Test method for {@link CheckingAccount#equals(java.lang.Object)}.
	 */
	@Test
	public void testEqualsObject() {
		assertTrue(my_account_tester1.equals(my_account_tester1));
		assertFalse(my_account_tester1.equals(my_account_tester2));
	}

}
